﻿using System.Data.Common;
using Microsoft.EntityFrameworkCore;

namespace Mt.Site.EntityFrameworkCore
{
    public static class MtSiteDbContextConfigurer
    {
        //EF Core 3.0 从 Preview 6 开始不支持UseRowNumberForPaging，
        public static void Configure(DbContextOptionsBuilder<MtSiteDbContext> builder, string connectionString)
        {
            //builder.UseMySql(connectionString, 
            //    new MySqlServerVersion(ServerVersion.AutoDetect(connectionString)), optionsBuilder =>
            //    {
            //        optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
            //    });

            builder.UseSqlServer(connectionString);


            //builder.LogTo(msg =>
            //{
            //    //调试-窗口消息
            //    System.Diagnostics.Debug.WriteLine(msg);
            //    //输出-窗口消息
            //    Console.WriteLine(msg);
            //});
        }

        public static void Configure(DbContextOptionsBuilder<MtSiteDbContext> builder, DbConnection connection)
        {
            //builder.UseMySql(connection,
            //    ServerVersion.AutoDetect(connection.ConnectionString), optionsBuilder =>
            //    {
            //        optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
            //    });

            builder.UseSqlServer(connection);


            //builder.LogTo(msg =>
            //{
            //    //调试-窗口消息
            //    System.Diagnostics.Debug.WriteLine(msg);
            //    //输出-窗口消息
            //    Console.WriteLine(msg);
            //});
        }
    }
}
